home *** CD-ROM | disk | FTP | other *** search
- function prepare(str)
- {
- clearUp();
- if(str == "")
- {
- return undefined;
- }
- numCurrent = -1;
- strPlaylistID = str;
- enabled = true;
- var xmlAdverts = new XML();
- xmlAdverts.ignoreWhite = true;
- xmlAdverts.onLoad = function()
- {
- xmlPlaylist = xmlAdverts.byPath("adverts/@" + strPlaylistID);
- delete xmlAdverts;
- next();
- };
- xmlAdverts.load(ADVERTS_DATA);
- }
- function start()
- {
- next();
- }
- function clearUp()
- {
- mc_file.unloadMovie();
- delete mc_file.onEnterFrame;
- clearInterval(numWaitID);
- enabled = false;
- delete strPlaylistID;
- delete xmlPlaylist;
- }
- function onClicked()
- {
- if(Tardis.Childlock.active == true)
- {
- return undefined;
- }
- var strWebURL = ndCurrent.attributes.web;
- if(strWebURL != null)
- {
- Tardis.webPageOpen(strWebURL);
- }
- else
- {
- if(Tardis.PLAY_MODE == "browser")
- {
- return undefined;
- }
- var file = ndCurrent.attributes.overlay;
- if(file == null || file == "")
- {
- error("adverts : onClicked : no file specified");
- }
- else
- {
- interrupt();
- Tardis.transition.clrTint = parseInt("0x" + ndCurrent.attributes.overlaycolor);
- Tardis.overlay.showAdvert(file);
- var strLog = xmlPlaylist.attributes.index + "." + numCurrent;
- Tardis.UsageData.addAdvertEntry(strLog);
- }
- }
- }
- function onAnimationfinished()
- {
- fadeDown();
- }
- function interrupt()
- {
- if(enabled == false)
- {
- error("adverts : interrupt : adverts not enabled");
- }
- var strWaitMode = ndCurrent.attributes.wait;
- switch(strWaitMode)
- {
- case "swfend":
- mc_file.onEnterFrame = null;
- mc_file.stop();
- break;
- case "static":
- case "script":
- break;
- default:
- if(parseInt(strWaitMode) == strWaitMode)
- {
- clearInterval(numWaitID);
- break;
- }
- }
- }
- function resume()
- {
- if(enabled == false)
- {
- error("adverts : resume : adverts not enabled");
- }
- startWait();
- }
- function fadeDown()
- {
- clearInterval(numWaitID);
- if(enabled == false)
- {
- return undefined;
- }
- mc_file.onEnterFrame = function()
- {
- with(this)
- {
- _alpha -= 10;
- if(_alpha <= 0)
- {
- onEnterFrame = null;
- _parent.next();
- }
- }
- };
- }
- function fadeUp()
- {
- with(this)
- {
- _alpha += 10;
- if(_alpha >= 100)
- {
- _alpha = 100;
- play();
- onEnterFrame = null;
- _parent.enableButton();
- _parent.startWait();
- }
- }
- }
- function next()
- {
- numCurrent++;
- if(numCurrent == xmlPlaylist.childNodes.length)
- {
- numCurrent = 0;
- }
- ndCurrent = xmlPlaylist.byIndex(numCurrent);
- mc_file.removeMovieClip();
- this.createEmptyMovieClip("mc_file",++depth);
- mc_file._alpha = 0;
- var f = function()
- {
- this.onLoad = null;
- this.onEnterFrame = this._parent.fadeUp;
- };
- mc_file = _parent.adverts.mc_file;
- mc_file.onLoad = f;
- mc_file.loadMovie(ADVERT_PATH + ndCurrent.attributes.file);
- trace("****** load advert: " + (ADVERT_PATH + ndCurrent.attributes.file));
- }
- function enableButton()
- {
- §§push(mc_file);
- §§push("onRelease");
- if(ndCurrent.attributes.usebutton == "false")
- {
- §§push(null);
- }
- §§pop()[§§pop()] = §§pop();
- mc_file.onRollOver = function()
- {
- onRollover();
- };
- }
- function startWait()
- {
- var strWaitMode = ndCurrent.attributes.wait;
- switch(strWaitMode)
- {
- case "swfend":
- mc_file.play();
- mc_file.onEnterFrame = function()
- {
- with(this)
- {
- if(_currentframe == _totalframes)
- {
- stop();
- onEnterFrame = null;
- _parent.fadeDown();
- }
- }
- };
- break;
- case "static":
- case "script":
- break;
- default:
- if(parseInt(strWaitMode) == strWaitMode)
- {
- numWaitID = setInterval(this,"fadeDown",strWaitMode * 1000);
- break;
- }
- error("startWait : wait mode not recognised");
- break;
- }
- }
- stop();
- ADVERT_PATH = Tardis.ASSETS_FOLDER + "adverts/";
- ADVERTS_DATA = Tardis.ASSETS_FOLDER + "xml/adverts.xml";
- var numWaitID;
- var numCurrent;
- var clpMask = this.createEmptyMovieClip("mc_mask",++depth);
- var w = 187;
- var h = 105;
- clpMask.moveTo(0,0);
- clpMask.beginFill(16711680);
- clpMask.lineTo(w,0);
- clpMask.lineTo(w,h);
- clpMask.lineTo(0,h);
- clpMask.lineTo(0,0);
- clpMask.endFill();
- this.setMask(clpMask);
- var enabled = false;
- this.onUnload = function()
- {
- clearUp();
- };
-